/*
package com.javasm.crm.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.javasm.crm.domin.criteria.ExampleCriteria;
import com.javasm.crm.domin.entity.Example;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

*/
/**
 * @Author: lirui
 * @Version: 1.0
 * @Date: 2021/7/3-19:49
 * @Since: jdk1.8
 * @Description: TODO
 *//*


@RestController
@RequestMapping("User")
@Api(value = "UserController", description = "用户管理")
public class ExampleController {

    @Autowired
    ExampleService exampleService;

    */
/**
     * 分页查询、条件查询
     *
     * @return 查询结果
     *//*

    @GetMapping("getUser")
    @ApiOperation(value = "查询用户", notes = "查询所有用户")
    public Page<Example> getUser() {

        //分页查询
        Long currentPage = 1L, pageSize = 10L;

        Page<Example> userPage = new Page<>(currentPage, pageSize);
        Page<Example> page = exampleService.page(userPage);

        */
/*
          这里page为查询结果，page中的records字段为结果列表，currentPage当前页, pageSize每页条数
          total总页数自动生成。当然，分页功能也可以使用pagehelper实现
          List<Example> users = page.getRecords();
         *//*


        return page;
    }


    @GetMapping("getCriteria")
    @ApiOperation(value = "条件查询", notes = "条件查询")
    public Page<Example> getCri(ExampleCriteria exampleCriteria) {
        Integer currentPage = exampleCriteria.getCurrentPage();
        Integer pageSize = exampleCriteria.getPageSize();

        if (StringUtils.isEmpty(currentPage)) {
            currentPage = 1;
        }
        if (StringUtils.isEmpty(pageSize)) {
            pageSize = 5;
        }

        LocalDateTime startTime = exampleCriteria.getStartTime();
        LocalDateTime endTime = exampleCriteria.getEndTime();
        String naMe = exampleCriteria.getNaMe();

        QueryWrapper<Example> exampleQueryWrapper = new QueryWrapper<>();
        LambdaQueryWrapper<Example> lambda = exampleQueryWrapper.lambda();

        if (!StringUtils.isEmpty(naMe)) {
            lambda.like(Example::getNaMe, naMe);
        }

        Page<Example> examplePage = new Page<>(currentPage, pageSize);
        exampleService.page(examplePage, exampleQueryWrapper);

        */
/*
         * 老师的写法，供参考。
         * Integer currentPage = brandCriteria.getCurrentPage();
         *         Integer pageSize = brandCriteria.getPageSize();
         *
         *         if (StringUtils.isEmpty(currentPage)) {
         *             currentPage = 1;
         *         }
         *         if (StringUtils.isEmpty(pageSize)) {
         *             pageSize = 5;
         *         }
         *
         *         PageHelper.startPage(currentPage, pageSize);
         *         LocalDateTime startTime = brandCriteria.getStartTime();
         *         LocalDateTime endTime = brandCriteria.getEndTime();
         *         String brandName = brandCriteria.getBrandName();
         *
         *         QueryWrapper<GiftBrand> brandQueryWrapper = new QueryWrapper<>();
         *         LambdaQueryWrapper<GiftBrand> lambda = brandQueryWrapper.lambda();
         *
         *
         *         //拼接sql的
         *         if (startTime != null && endTime != null) {
         *             lambda.between(GiftBrand::getCreateTime, startTime, endTime);
         *         }
         *
         *         if (!StringUtils.isEmpty(brandName)) {
         *             lambda.like(GiftBrand::getBrandName, brandName);
         *         }
         *
         *
         *         List<GiftBrand> brandList = brandMapper.selectList(brandQueryWrapper);
         *
         *         PageInfo<GiftBrand> brandPageInfo = new PageInfo<>(brandList);
         *
         *         long total = brandPageInfo.getTotal();
         *
         *         //brandList ------>brandVoList
         *
         *         List<BrandVo> brandVoList = brandTransfer.toVO(brandList);
         *//*

        return examplePage;
    }

    @PostMapping("save")
    @ApiOperation(value = "插入用户", notes = "添加用户")
    public long saveUser(@RequestBody Example user) {
        boolean save = exampleService.save(user);

    */
/*
      mybatisplus会在保存时，自动向示例中set数据库生成的id，直接getid即可得到
     *//*

        return user.getId();
    }

    @DeleteMapping("delete")
    @ApiOperation(value = "删除用户", notes = "删除用户")
    public int deleteUser(Integer id) {
        boolean b = exampleService.removeById(id);
        return b ? 1 : 0;
    }

    @PutMapping("update")
    @ApiOperation(value = "更新用户", notes = "更新用户")
    public int updateUser(@RequestBody Example user) {

        boolean b = exampleService.updateById(user);

        return b ? 1 : 0;
    }
}
*/
